﻿
using System;
using System.Collections.Generic;

namespace WaterResources
{
    class WaterEnvironment : IWaterEnvironmentDb
    {
        public int Id { get; set; }
        public int Level { get; set; }
        public string Levelname { get; set; }
        public string Name { get; set; }
        public string Area { get; set; }
        public string Start { get; set; }
        public string End { get; set; }
        public decimal targetL1 { get; set; }
        public decimal targetL2 { get; set; }
        public decimal targetC1 { get; set; }
        public decimal targetC2 { get; set; }
        public decimal targetC3 { get; set; }
        public decimal WaterNA { get; set; }
        public decimal WaterPA { get; set; }
        public decimal WaterCODA { get; set; }
        public decimal WaterNB { get; set; }
        public decimal WaterPB { get; set; }
        public decimal WaterCODB { get; set; }
        public string WaterNC { get; set; }
        public string WaterPC { get; set; }
        public string WaterCODC { get; set; }
        
        public DateTime Time { get; set; }

        public IList<string> GetCols()
        {

            return new List<string>
            {
                "编号",
                "河道等级",
                "河道名称",
                "河道所属辖区",
                "起点",
                "终点",
                "取样河道水深(L)",
                "试验水柱高度(L)",
                "上覆水水质(mg/L)",
                "目标水质(mg/L)",
                "平衡后水质(mg/L)",
                "总氮(目标水质)(mg/L)",
                "总磷(目标水质)(mg/L)",
                "COD(目标水质)(mg/L)",
                "总氮(试验水质)(mg/L)",
                "总磷(试验水质)(mg/L)",
                "COD(试验水质)(mg/L)",
                "总氮(判定结果)(mg/L)",
                "总磷(判定结果)",
                "COD(判定结果)",
                "录入时间",
            };
        }

        public IList<string> GetMaps()
        {

            return new List<string>
            {
                Id.ToString(), // 编号
                Level.ToString(), // 河道防洪排涝等级
                Levelname,
                Name, // 河道名称
                Area, // 河道所属辖区
                Start, // 河道起点
                End, // 河道终点
                targetL1.ToString("N2"), // 取样点河道水深
                targetL2.ToString("N2"), // 实验水柱高度
                targetC1.ToString("N2"), // 目标水质
                targetC2.ToString("N2"), // 实验上覆水水质
                targetC3.ToString("N2"), // 底泥污染物释放平衡后河道水质
                WaterNA.ToString("N2"), // 目标水质总氮
                WaterPA.ToString("N2"), // 目标水质总磷
                WaterCODA.ToString("N2"), // 目标水质总COD
                WaterNB.ToString("N2"), // 试验水质总氮
                WaterPB.ToString("N2"), // 试验水质总磷
                WaterCODB.ToString("N2"), // 试验水质总COD
                WaterNC, // 判定结果总氮
                WaterPC, // 判定结果总磷
                WaterCODC, // 判定结果总COD
                Time.ToString("F"), // 录入时间
            };
        }
        
        public string GetFindSql()
        {
            return "select id, level, name, area, start, end,targetl1,targetl2,targetc1,targetc2,targetc3, waterna, waterpa, watercoda, waternb, waterpb, watercodb, waternc, waterpc, watercodc, time from water_environment";
        }

        public string GetSaveSql()
        {
            return @"insert into 
water_environment(level, name, area, start, end, waterna, waterpa, watercoda, waternb, waterpb, watercodb, waternc, waterpc, watercodc,targetl1,targetl2,targetc1,targetc2,targetc3, time) 
values(@Level, @Name, @Area, @Start, @End, @WaterNA, @WaterPA, @WaterCODA, @WaterNB, @WaterPB, @WaterCODB, @WaterNC, @WaterPC, @WaterCODC,@targetL1,@targetL2,@targetC1,@targetC2,@targetC3
, @Time)";
        }

        public string GetEditSql()
        {
            return @"update water_environment set 
level=@Level, name=@Name, area=@Area, start=@Start, end=@End, waterna=@WaterNA, waterpa=@WaterPA, watercoda=@WaterCODA, 
waternb=@WaterNB, waterpb=@WaterPB, watercodb=@WaterCODB, waternc=@WaterNC, waterpc=@WaterPC, watercodc=@WaterCODC,targetl1=@targetL1,targetl2=@targetL2,targetc1=@targetC1,targetc2=@targetC2,targetc3=@targetC3, time=@Time
where id=@Id";
        }

        public string GetDropSql()
        {
            return @"delete from water_environment where id=@Id";
        }
    }
}
